package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Order;
import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    @Select("select count(1)  from t_order where MEMBER_ID=#{memberId} and  ORDERDATE=#{orderDate}  and  SETMEAL_ID=#{setmealId}")
    int findOrderIsExistByOrderDateAndSetmealIdAndMemberId(@Param("orderDate") String orderDate, @Param("setmealId") int setmealId, @Param("memberId") Integer memberId);

    @Select("select a.ORDERDATE as orderDate,a.ORDERTYPE as orderType,m.NAME as member,s.NAME as setmeal from t_order a inner join t_member m on a.member_id=m.id inner join t_setmeal s on a.SETMEAL_ID=s.ID where a.ID=#{order}")
    Map findOrderMessagebyid(@Param("order") Integer orderid);
}
